<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Admin Dispatch Email</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<% 'on error resume next %>
<body>
<form id="DispatchEmailForm" name="DispatchEmailForm" method="post" action="AdminDispatchEmail.asp?action=save">
 <p>&nbsp;</p>
 <table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#006600" style="border-style:outset; border-width:thin">
  <tr>
   <td bgcolor="#FFFFFF" class="TableTitles">
   
    <p>
     <%
   dim rs,conn
set fs=server.CreateObject("scripting.filesystemobject")

set rs=server.CreateObject("adodb.recordset")
set conn=server.CreateObject("adodb.connection")

filepath=server.MapPath("access/backend/Admin.mdb")

if fs.fileexists (filepath) then
	'response.Write(filepath & " found.")
else
	response.Write(filepath & " not found")
	response.End()
end if

conn.open ("provider=microsoft.jet.oledb.4.0;data source=" & filepath)
rs.cursorlocation=3 'adUseClient
rs.cursortype=0 'adOpenForwardOnly 
rs.locktype = 3 'adLockOptimistic  
sql="select top 1 * from DispatchEmail" 
rs.open sql,conn
msg=""

if request.QueryString("action")="save" then
	rs("send_dispatch_email_new")=request.Form("emailnew")
	rs("send_dispatch_email_existing")=request.Form("emailexisting")
	rs("dispatch_email")=request.Form("dispatchemail")
	rs.update
	if err.number<>0 then
		
	else
		%><script type="text/javascript">alert( "Dispatch Email Settings Saved.")</script><%
	end if

end if

if not rs.eof then rs.movefirst
emailnew=rs("send_dispatch_email_new")
emailexisting=rs("send_dispatch_email_existing")
dispatchemail=rs("dispatch_email")

'if rs.state=1 then rs.close
set rs=nothing
%>
    <p>&nbsp;</p>
    <p class="ResultsName">Send dispatchers an Email when operators have:</p>
    <p>&nbsp;</p>
    <p> &nbsp; - Created a new ticket:</p>
    <p>&nbsp;&nbsp; yes
    <% if emailnew=true then chk="checked=checked" else chk="" %>
     <input name="emailnew" type="radio" value=-1 <%= chk %>/>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    no
    <% if emailnew=false then chk="checked=checked" else chk="" %>
    <input name="emailnew" type="radio" value=-0 <%= chk %>/>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp; - Changed / added to an existing ticket:</p>
    <p>&nbsp;&nbsp; yes
    <% if emailexisting=true then chk="checked=checked" else chk="" %>
     <input name="emailexisting" type="radio" value=-1 <%= chk %>/>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    no
    <% if emailexisting=false then chk="checked=checked" else chk="" %>
    <input name="emailexisting" type="radio" value=0 <%= chk %>/>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p class="ResultsName">Dispatcher Email Address:</p>
    <p class="ResultsName">
     <input name="dispatchemail" type="text" id="dispatchemail" value="<%= dispatchemail %>" />
    </p>
   </td>
  </tr>
  <tr>
   <td align="right" bgcolor="#FFFFFF"><img src="Images/SaveButton.png" alt="Save" name="BtnSave" width="60" height="30" id="BtnSave" onclick="javascript: DispatchEmailForm.submit()"/>&nbsp; </td>
  </tr>
 </table>
</form>
</body>
</html>
